package com.highcom.sql;

import com.highcom.bean.Student;
import org.apache.ibatis.jdbc.SQL;

public class ReturnSql {
    public String getSelectAll() {
        return new SQL() {
            {
                SELECT("*");
                FROM("student");
                //WHERE("id = #{id}");
            }
        }.toString();
    }

    public String getSelectById(Integer id) {
        return new SQL() {
            {
                SELECT("*");
                FROM("student");
                WHERE("id = #{id}");
            }
        }.toString();
    }

    public String insertStudent(Student student) {
        return new SQL() {
            {
                INSERT_INTO("student");
                VALUES("name", "#{name}");
                VALUES("age", String.valueOf(student.getAge()));
            }
        }.toString();
    }

    public String deleteStudent(Student student) {
        return new SQL() {
            {
                DELETE_FROM("student");
                WHERE("id = #{id}");
            }
        }.toString();
    }

    public String updateStudent(Student studnet){
        return new SQL(){
            {
                UPDATE("student");
                SET("name=#{name}","age=#{age}");
                WHERE("id=#{id}");
            }
        }.toString();
    }

}
